<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		看书：<input type="checkbox" name="checkbox" value=1><br>
		写字：<input type="checkbox" name="checkbox"value=2><br>
		打飞机：<input type="checkbox" name="checkbox"value=3><br>
		玩游戏：<input type="checkbox" name="checkbox"value=4><br>
		<button onclick="allcheck()">全选/取消</button>
		<script>
	   var checkAll = false;
       function allcheck(){
	         checkAll = !checkAll;
	         var inputs = document.getElementsByName('checkbox')
	         for(var i =0;i<inputs.length;i++){
	    	   inputs[i].checked = checkAll;
	         }
      }
		</script>
	</body>
</html>
